﻿using BBCore.Core.Models.Admins;
using BootstrapBlazor.Components;
using Microsoft.AspNetCore.Components;
using System.Diagnostics.CodeAnalysis;

namespace BBCore.Server.Components.Pages.Admins.Icon
{
    public partial class SelectIconEditor_HYJ
    {
        [Parameter]
        [EditorRequired]
        [NotNull]
        public MenuEntity? Value { get; set; }

        [Inject]
        [NotNull]
        private DialogService? DialogService { get; set; }
        private Task OnToggleIconDialog() => DialogService.Show(new DialogOption()
        {
            Title = "选择图标",
            ShowFooter = false,
            FullScreenSize = FullScreenSize.Medium,
            ShowMaximizeButton = true,
            Component = BootstrapDynamicComponent.CreateComponent<MenuIconList_HYJ>(new Dictionary<string, object?>()
            {
                [nameof(MenuIconList_HYJ.Value)] = Value.Icon,
                [nameof(MenuIconList_HYJ.ValueChanged)] = EventCallback.Factory.Create<string?>(this, v => Value.Icon = v)
            })
        });

        private Task OnClearIcon()
        {
            Value.Icon = null;
            return Task.CompletedTask;
        }
    }
}
